///*
//
//package com.acmedcare.framework.plugin.sample;
//
//import com.acmedcare.framework.exchange.center.core.PluginContainer;
//import com.acmedcare.framework.exchange.center.core.PluginContainerMBean;
//import com.acmedcare.framework.exchange.center.core.PluginMetadata;
//import com.acmedcare.framework.exchange.center.core.adapter.DefaultAdapterResolver;
//import com.acmedcare.framework.exchange.center.core.agent.DefaultAgentResolver;
//import com.acmedcare.framework.exchange.center.core.application.LocalApplicationResolver;
//import com.acmedcare.framework.exchange.center.core.consumer.DefaultConsumerResolver;
//import com.acmedcare.framework.exchange.center.core.handler.PluginHandler;
//import com.acmedcare.framework.exchange.center.core.handler.Request;
//import com.acmedcare.framework.exchange.center.core.json.DefaultExtensionConvert;
//import com.acmedcare.framework.exchange.center.core.json.IPluginExtensionConvert;
//import com.acmedcare.framework.exchange.center.core.metadata.ResponseConvert;
//import com.acmedcare.framework.exchange.center.entity.bean.Plugin;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import org.springframework.http.HttpMethod;
//
//public class MainTest {
//
//  public static void main(String[] args) throws Exception {
//
//    //构造容器
//    ObjectMapper objectMapper = new ObjectMapper();
//    IPluginExtensionConvert pluginExtensionConvert = new DefaultExtensionConvert(objectMapper);
//    PluginContainerMBean pluginContainer = new PluginContainer(new DefaultAdapterResolver(),
//        pluginExtensionConvert, new DefaultAgentResolver(), new LocalApplicationResolver(),
//        new DefaultConsumerResolver(), objectMapper);
//
//    List<Plugin> metadataList = new ArrayList<>();
//    PluginMetadata metadata = new PluginMetadata();
//    metadata.setName("demo");
//    metadata.setBasePackageName("com.acmedcare.framework.plugin.sample");
//    metadata.setVersion("1.0.0");
//    metadataList.add(metadata);
//    pluginContainer.init(metadataList);
//
//    //构造插件处理器
//    PluginHandler pluginHandler = new PluginHandler(objectMapper,
//        pluginContainer);
//
//    Thread.currentThread().sleep(5000);
//    Request request = new Request();
//    request.setUrl("demoAdapter");
//    request.setPluginName("demo");
//    DemoDto demoDto = new DemoDto();
//    SubDemoDto subDemoDto = new SubDemoDto();
//    subDemoDto.setDescription("just test");
//
//    demoDto.setDate(new Date());
//    demoDto.setName("demo");
//    demoDto.setData("data");
//    demoDto.setDemoDto(subDemoDto);
//    request.setBody(objectMapper.writeValueAsString(demoDto));
//    request.setHttpMethod(HttpMethod.GET);
//    ResponseConvert response = pluginHandler.invoke(request);
//
//*/
///*    //构造采集器
//    AgentHandlerMBean agentHandler = new DefaultAgentHandler(pluginContainer, objectMapper);
//    Task task = new Task();
//    task.setName("demoAgent");
//    task.setSchedulerType(SchedulerType.AGENT);
//    task.setPluginName("demo");
//    task.setAgentName("com.acmedcare.framework.plugin.sample.DemoAgent");
//
//    //构造消息处理器
//    Consumer consumer = new Consumer();
//    consumer.setConsumerName("com.acmedcare.framework.plugin.sample.ConsumerDemo");
//    consumer.setPluginName("demo");
//    ConsumerHandlerMBean consumerHandler = new ConsumerHandler(objectMapper, pluginContainer,
//        consumer, null);
//
//    agentHandler.invoke(task, (name, obj) -> {
//      try {
//
//        String dataString = objectMapper.writeValueAsString(obj);
//        consumerHandler.invoke(dataString);
//      } catch (Exception e) {
//        e.getStackTrace();
//      }
//    });
//    System.out.println("response:" + response.getStatus());*//*
//*/
///*
//*//*
//
//  }
//}
//*/
